cmake_minimum_required(VERSION 2.8.3)
project(communication)



## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
  pluginlib
  roscpp
  geometry_msgs
  sensor_msgs
  nav_msgs
  std_msgs
  std_srvs
  tf2_ros
  angles
  libmavconn
  augmavconn
  rosconsole_bridge
  eigen_conversions
  mavros_msgs
  smarteye_common
)

## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)
find_package(Boost REQUIRED COMPONENTS system thread)

find_package(Eigen3)
if(NOT EIGEN3_FOUND)
  # Fallback to cmake_modules
  find_package(cmake_modules REQUIRED)
  find_package(Eigen REQUIRED)
  set(EIGEN3_INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS})
  set(EIGEN3_LIBRARIES ${EIGEN_LIBRARIES})
endif()

include(EnableCXX11)
include(MavrosMavlink)

## Uncomment this if the package has a setup.py. This macro ensures
## modules and global scripts declared therein get installed
## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
catkin_python_setup()


###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if you package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
  INCLUDE_DIRS include
  LIBRARIES mavros
  CATKIN_DEPENDS  pluginlib roscpp sensor_msgs nav_msgs std_msgs tf2_ros geometry_msgs libmavconn message_runtime eigen_conversions mavros_msgs augmavconn
  DEPENDS Boost Eigen
)

###########
## Build ##
###########

include_directories(
  include
  ${catkin_INCLUDE_DIRS}
  ${Boost_INCLUDE_DIRS}
  ${mavlink_INCLUDE_DIRS}
  ${EIGEN3_INCLUDE_DIRS}
)

add_library(communication
	src/lib/communication.cpp
        #src/lib/uas_data.cpp
        #src/lib/uas_stringify.cpp
        #src/lib/uas_timesync.cpp
        #src/lib/uas_sensor_orientation.cpp
        #src/lib/uas_frame_conversions.cpp
        #src/lib/uas_quaternion_utils.cpp
	
)
target_link_libraries(communication
  ${catkin_LIBRARIES}
  ${Boost_LIBRARIES}
)
add_dependencies(communication communication_msgs_generate_messages_cpp)

add_library(commplugin
  src/plugins/waypoint.cpp
  src/plugins/param.cpp
  src/plugins/paramcoord.cpp
  src/plugins/state_sp.cpp
  src/plugins/vehicle_pos_pub.cpp
  src/plugins/command.cpp
)
add_dependencies(commplugin
  communication
)
target_link_libraries(commplugin
  communication
  ${catkin_LIBRARIES}
  ${Boost_LIBRARIES}
)

## Declare a cpp executable
add_executable(communication_node
  src/communication_node.cpp
)
add_dependencies(communication_node
  communication
)
target_link_libraries(communication_node
  communication
  ${catkin_LIBRARIES}
  ${Boost_LIBRARIES}
)


#############
## Install ##
#############

## Mark executables and/or libraries for installation
 install(TARGETS communication communication_node commplugin
  ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

### Mark cpp header files for installation
install(DIRECTORY include/${PROJECT_NAME}/
  DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
  FILES_MATCHING PATTERN "*.h"
)


install(FILES
  commplugin.xml
  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

install(DIRECTORY launch/
  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
)

install(DIRECTORY config/
  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/config
)

#############
## Testing ##
#############


